package org.dandsoft.blackbox.logger;

import java.util.Map;
import java.util.Hashtable;
import java.util.LinkedList;

/**
 * User: dvilyuzhanin
 * Date: 21.01.2009 14:20:01
 */
public class ParameterGroupLogger implements Logger {

    private String groupParameterName;
    private Map<Object, LinkedList<Message>> messages = new Hashtable<Object, LinkedList<Message>>();

    public ParameterGroupLogger(String groupParameterName) {
        this.groupParameterName = groupParameterName;
    }

    public String getGroupParameterName() {
        return groupParameterName;
    }

    public void log(Message message) {
        Object key = message.getParameters().get(groupParameterName);
        LinkedList<Message> list = messages.get(key);
        if (list == null) {
            list = new LinkedList<Message>();
            messages.put(key, list);
        }
        list.add(message);
    }
}
